package com.hengyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hengyi.common.annotation.Log;
import com.hengyi.common.base.Result;
import com.hengyi.common.enums.BusinessType;
import com.hengyi.common.page.TableDataInfo;
import com.hengyi.common.utils.poi.ExcelUtil;
import com.hengyi.framework.web.base.BaseController;
import com.hengyi.system.domain.TMemberInfo;
import com.hengyi.system.service.ITMemberInfoService;

/**
 * 用户扩展 信息操作处理
 * 
 * @author qianjiang
 * @date 2019-03-14
 */
@Controller
@RequestMapping("/system/tMemberInfo")
public class MemberInfoController extends BaseController
{
    private String prefix = "system/tMemberInfo";
	
	@Autowired
	private ITMemberInfoService tMemberInfoService;
	
	@RequiresPermissions("system:tMemberInfo:view")
	@GetMapping()
	public String tMemberInfo()
	{
	    return prefix + "/tMemberInfo";
	}
	
	/**
	 * 查询用户扩展列表
	 */
	@RequiresPermissions("system:tMemberInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TMemberInfo tMemberInfo)
	{
		startPage();
        List<TMemberInfo> list = tMemberInfoService.selectTMemberInfoList(tMemberInfo);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出用户扩展列表
	 */
	@RequiresPermissions("system:tMemberInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public Result export(TMemberInfo tMemberInfo)
    {
    	List<TMemberInfo> list = tMemberInfoService.selectTMemberInfoList(tMemberInfo);
        ExcelUtil<TMemberInfo> util = new ExcelUtil<TMemberInfo>(TMemberInfo.class);
        return util.exportExcel(list, "tMemberInfo");
    }
	
	/**
	 * 新增用户扩展
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存用户扩展
	 */
	@RequiresPermissions("system:tMemberInfo:add")
	@Log(title = "用户扩展", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public Result addSave(TMemberInfo tMemberInfo)
	{		
		return toAjax(tMemberInfoService.insertTMemberInfo(tMemberInfo));
	}

	/**
	 * 修改用户扩展
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		TMemberInfo tMemberInfo = tMemberInfoService.selectTMemberInfoById(id);
		mmap.put("tMemberInfo", tMemberInfo);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存用户扩展
	 */
	@RequiresPermissions("system:tMemberInfo:edit")
	@Log(title = "用户扩展", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public Result editSave(TMemberInfo tMemberInfo)
	{		
		return toAjax(tMemberInfoService.updateTMemberInfo(tMemberInfo));
	}
	
	/**
	 * 删除用户扩展
	 */
	@RequiresPermissions("system:tMemberInfo:remove")
	@Log(title = "用户扩展", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public Result remove(String ids)
	{		
		return toAjax(tMemberInfoService.deleteTMemberInfoByIds(ids));
	}
	
}
